﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Codeplex.InertialScroll.UTest
{
    [TestClass]
    public class UnitTests
    {
        [TestMethod]
        public void TraversalScrollTest()
        {
            double start = 100;
            double stop  = 10100;

            TraversalState  state  = new TraversalState(start, stop);
            TraversalScroll scroll = new TraversalScroll();

            state = scroll.Calculate(1500, state);
            Assert.IsTrue(state.CurrentPosition == start + (stop - start) / 2);

            double constantSpeedDistance = state.Speed * TraversalState.CONSTANT_SPEED_TIME;
            double accelerationDistance  = ((stop - start) - constantSpeedDistance) / 2;

            state = new TraversalState(start, stop);
            state = scroll.Calculate(1000, state);
            Assert.IsTrue(state.CurrentPosition == start + accelerationDistance);

            state = new TraversalState(start, stop);
            state = scroll.Calculate(2000, state);
            Assert.IsTrue(state.CurrentPosition == start + accelerationDistance + constantSpeedDistance);

            state = new TraversalState(start, stop);
            state = scroll.Calculate(3000, state);
            Assert.IsTrue(state.CurrentPosition == start + 2 * accelerationDistance + constantSpeedDistance);
        }
    }
}
